package Thread;

class  MyThread3 extends Thread{
    @Override
    public void run() {
        while (true){
            System.out.println("这是线程3在打招呼 hallo t3");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo5 {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while (true){
                System.out.println("这是对Thread类中属性 getId的线程+hallo t1");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t1.start();
        Thread t2 = new Thread(()->{
            while (true){
                System.out.println("hello t2");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t2.start();
        Thread t3 = new Thread(()->{
            System.out.println("hello t3");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        t3.start();
//        Thread t3 = new Thread();
//        t3.start();

        for (int i=0;i<3;i++){
            System.out.println("这是主线程在打招呼 hallo main");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
